
import sys
from pathlib import Path
 
from PySide6.QtCore import QObject, Slot
from PySide6.QtQml import QQmlApplicationEngine
from PySide6.QtQuick import QQuickItem
from PySide6.QtWidgets import QApplication, QWidget, QPushButton
 
class TestWidget(QWidget):
    def __init__(self, parent=None):
        super(TestWidget, self).__init__(parent)
        self.button_open = QPushButton(self)
        self.button_open.setText("打开Qml窗口")
        self.button_open.setGeometry(0, 100, 100, 50)
        self.button_open.clicked.connect(self.handle_button_open_click)
        self.button_close = QPushButton(self)
        self.button_close.setText("关闭Qml窗口")
        self.button_close.setGeometry(100, 100, 100, 50)
        self.button_close.clicked.connect(self.handle_button_close_click)
 
    # 打开Qml窗口
    def handle_button_open_click(self):
        self.widget = LoginQuickWidget()
 
    # 关闭Qml窗口
    def handle_button_close_click(self):
        if hasattr(self, 'widget') and self.widget:
            del self.widget
 
 
if __name__ == '__main__':
    app = QApplication([])
    widget = TestWidget()
    widget.show()
    app.exec()
